package com.example.gameandroid;

import com.badlogic.gdx.physics.box2d.Body;
import com.badlogic.gdx.physics.box2d.ContactImpulse;
import com.badlogic.gdx.physics.box2d.ContactListener;
import com.badlogic.gdx.physics.box2d.Manifold;

public class Contact implements ContactListener {
	
	private Body body;
	private Player player;
	
	public Contact(Body body, Player player) {
		this.body = body;
		this.player = player;
	
	}

	@Override
	public void beginContact(com.badlogic.gdx.physics.box2d.Contact contact) {
		String obj1 = (String) contact.getFixtureA().getBody().getUserData();
		String obj2 = (String) contact.getFixtureB().getBody().getUserData();  
		
		if((obj1.equals("chao") && obj2.equals("player")) || (obj2.equals("chao") && obj1.equals("player"))){
			body.setLinearVelocity(body.getLinearVelocity().x, 0);
		}		
		
		player.setOnFloor(true);
	}

	@Override
	public void endContact(com.badlogic.gdx.physics.box2d.Contact contact) {
		
	}

	@Override
	public void preSolve(com.badlogic.gdx.physics.box2d.Contact contact,
			Manifold oldManifold) {

	}

	@Override
	public void postSolve(com.badlogic.gdx.physics.box2d.Contact contact,
			ContactImpulse impulse) {
		// TODO Auto-generated method stub
		
	}
	

}
